import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author chen.haogang
 *
 */
public class MinScalarProduct2 {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader("".getClass().getResourceAsStream("/A-small-practice.in")));
			String testCaseNumber = br.readLine();
			System.out.println(testCaseNumber);
			for(int i = 0; i < Integer.valueOf(testCaseNumber); i++) {
				int product = 0;
				String intNumber = br.readLine();
				List<Integer> vector1 = getVector(br, intNumber);
				List<Integer> vector2 = getVector(br, intNumber);
				product = getMinimumScalarProduct(vector1, vector2);
				System.out.println("Case #" + (i + 1) + ": " + product);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private static List<Integer> getVector(BufferedReader br, String intNumber) throws IOException {
		String[] numbers = br.readLine().split(" ");
		List<Integer> vector1 = new ArrayList<Integer>();
		for(int j = 0; j < Integer.valueOf(intNumber); j++) {
			vector1.add(Integer.valueOf(numbers[j]));
		}
		return vector1;
	}

	private static int getMinimumScalarProduct(List<Integer> vector1,
			List<Integer> vector2) throws Exception {
		Collections.sort(vector1);
		Collections.sort(vector2);
		Collections.reverse(vector2);
		return getScalarProduct(vector1, vector2);
	}

	/**
	 * 2 vectors must have same length
	 * @param vector1
	 * @param vector2
	 * @return the scalar product of 2 vectors
	 * @throws Exception 
	 */
	private static int getScalarProduct(List<Integer> vector1,
			List<Integer> vector2) throws Exception {
		if(vector1.size() != vector2.size()) {
			throw new Exception("The vectors' length are not same!");
		}
		int product = 0;
		for(int i = 0, length = vector1.size(); i < length; i++) {
			product += vector1.get(i) * vector2.get(i);
		}
		return product;
	}

}
